

#include "arm_2d_helper.h"

#if defined(__clang__)
#   pragma clang diagnostic push
#   pragma clang diagnostic ignored "-Wunknown-warning-option"
#   pragma clang diagnostic ignored "-Wreserved-identifier"
#   pragma clang diagnostic ignored "-Wmissing-variable-declarations"
#   pragma clang diagnostic ignored "-Wcast-qual"
#   pragma clang diagnostic ignored "-Wmissing-declarations"
#   pragma clang diagnostic ignored "-Wgnu-variable-sized-type-not-at-end"
#   pragma clang diagnostic ignored "-Wimplicit-int-conversion"
#   pragma clang diagnostic ignored "-Wdeclaration-after-statement"
#   pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#   pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
#   pragma clang diagnostic ignored "-Wpadded"
#   pragma clang diagnostic ignored "-Wunused-parameter"
#   pragma clang diagnostic ignored "-Wunused-variable"
#   pragma clang diagnostic ignored "-Wsign-conversion"
#elif defined(__IS_COMPILER_GCC__)
#   pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
#   pragma GCC diagnostic ignored "-Wunused-variable"
#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
#   pragma diag_suppress=1296
#endif

typedef struct {
    uint16_t      hwIndex;
    arm_2d_size_t tCharSize;
    int16_t       iAdvance;
    int16_t       iBearingX;
    int16_t       iBearingY;
    uint8_t       chCodeLength;
    uint8_t       chUTF8[4];
} __ttf_char_descriptor_t;

ARM_SECTION("arm2d.asset.FONT")
const uint8_t c_bmpUTF8arial_16A1Font[] = {


    // Glyph for character {0x0a}
    0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0xff, 0x00,

    // Glyph for character {0x30}
    0x38, 0x00, 0x44, 0x00, 0xc6, 0x00, 0x82, 0x00, 0x82,
    0x00, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00, 0x82, 0x00,
    0xc6, 0x00, 0x44, 0x00, 0x38, 0x00,

    // Glyph for character {0x31}
    0x10, 0x00, 0x18, 0x00, 0x1c, 0x00, 0x12, 0x00, 0x10,
    0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00,
    0x10, 0x00, 0x10, 0x00, 0x10, 0x00,

    // Glyph for character {0x32}
    0x3c, 0x00, 0x46, 0x00, 0xc2, 0x00, 0x80, 0x00, 0xc0,
    0x00, 0x40, 0x00, 0x60, 0x00, 0x30, 0x00, 0x18, 0x00,
    0x0c, 0x00, 0x06, 0x00, 0xfe, 0x00,

    // Glyph for character {0x33}
    0x3c, 0x00, 0x66, 0x00, 0xc2, 0x00, 0xc0, 0x00, 0x60,
    0x00, 0x70, 0x00, 0xc0, 0x00, 0x80, 0x00, 0x80, 0x00,
    0xc2, 0x00, 0x46, 0x00, 0x3c, 0x00,

    // Glyph for character {0x34}
    0x60, 0x00, 0x70, 0x00, 0x70, 0x00, 0x78, 0x00, 0x6c,
    0x00, 0x64, 0x00, 0x66, 0x00, 0x62, 0x00, 0xff, 0x00,
    0x60, 0x00, 0x60, 0x00, 0x60, 0x00,

    // Glyph for character {0x35}
    0xfc, 0x00, 0x04, 0x00, 0x04, 0x00, 0x06, 0x00, 0x3e,
    0x00, 0xc6, 0x00, 0xc0, 0x00, 0x80, 0x00, 0x80, 0x00,
    0xc2, 0x00, 0x46, 0x00, 0x3c, 0x00,

    // Glyph for character {0x36}
    0x38, 0x00, 0x44, 0x00, 0xc6, 0x00, 0x02, 0x00, 0x3a,
    0x00, 0x46, 0x00, 0xc6, 0x00, 0x82, 0x00, 0x82, 0x00,
    0xc6, 0x00, 0x44, 0x00, 0x38, 0x00,

    // Glyph for character {0x37}
    0xfe, 0x00, 0xc0, 0x00, 0x60, 0x00, 0x20, 0x00, 0x30,
    0x00, 0x10, 0x00, 0x18, 0x00, 0x18, 0x00, 0x08, 0x00,
    0x08, 0x00, 0x0c, 0x00, 0x0c, 0x00,

    // Glyph for character {0x38}
    0x38, 0x00, 0x44, 0x00, 0xc6, 0x00, 0xc6, 0x00, 0x44,
    0x00, 0x7c, 0x00, 0xc6, 0x00, 0x82, 0x00, 0x82, 0x00,
    0x82, 0x00, 0xc6, 0x00, 0x3c, 0x00,

    // Glyph for character {0x39}
    0x38, 0x00, 0x46, 0x00, 0xc2, 0x00, 0x82, 0x00, 0x82,
    0x00, 0xc2, 0x00, 0xc6, 0x00, 0xbc, 0x00, 0x80, 0x00,
    0xc2, 0x00, 0x66, 0x00, 0x3c, 0x00,
    // a white space
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
};

ARM_SECTION("arm2d.asset.FONT")
 const __ttf_char_descriptor_t c_tUTF8arial_16LookUpTableA1[] = {

    { 0, { 8, 11, }, 12, 2, 11, 1, {0x0a} },
    { 11, { 9, 12, }, 9, 0, 12, 1, {0x30} },
    { 23, { 5, 12, }, 9, 1, 12, 1, {0x31} },
    { 35, { 9, 12, }, 9, 0, 12, 1, {0x32} },
    { 47, { 9, 12, }, 9, 0, 12, 1, {0x33} },
    { 59, { 9, 12, }, 9, 0, 12, 1, {0x34} },
    { 71, { 9, 12, }, 9, 0, 12, 1, {0x35} },
    { 83, { 9, 12, }, 9, 0, 12, 1, {0x36} },
    { 95, { 9, 12, }, 9, 0, 12, 1, {0x37} },
    { 107, { 9, 12, }, 9, 0, 12, 1, {0x38} },
    { 119, { 9, 12, }, 9, 0, 12, 1, {0x39} },
    { 131, { 9, 12, }, 9, 0, 12, 1, {0x20} },
};



ARM_SECTION("arm2d.tile.c_tileUTF8arial_16A1Mask")
static const arm_2d_tile_t c_tileUTF8arial_16A1Mask = {
    .tRegion = {
        .tSize = {
            .iWidth = 9,
            .iHeight = 132,
        },
    },
    .tInfo = {
        .bIsRoot = true,
        .bHasEnforcedColour = true,
        .tColourInfo = {
            .chScheme = ARM_2D_COLOUR_1BIT,
        },
    },
    .pchBuffer = (uint8_t *)c_bmpUTF8arial_16A1Font,
};

#define __UTF8_FONT_SIZE_1__



static
IMPL_FONT_GET_CHAR_DESCRIPTOR(__utf8_a1_font_get_char_descriptor)
{
    assert(NULL != ptFont);
    assert(NULL != ptDescriptor);
    assert(NULL != pchCharCode);

    arm_2d_user_font_t *ptThis = (arm_2d_user_font_t *)ptFont;
    ARM_2D_UNUSED(ptThis);

    memset(ptDescriptor, 0, sizeof(arm_2d_char_descriptor_t));

    ptDescriptor->tileChar.ptParent = (arm_2d_tile_t *)&ptFont->tileFont;
    ptDescriptor->tileChar.tInfo.bDerivedResource = true;

    /* use the white space as the default char */
    __ttf_char_descriptor_t *ptUTF8Char =
        (__ttf_char_descriptor_t *)&c_tUTF8arial_16LookUpTableA1[dimof(c_tUTF8arial_16LookUpTableA1)-1];

    arm_foreach(__ttf_char_descriptor_t, c_tUTF8arial_16LookUpTableA1, ptChar) {
        if (0 == strncmp(   (char *)pchCharCode,
                            (char *)ptChar->chUTF8,
                            ptChar->chCodeLength)) {
            /* found the UTF8 char */
            ptUTF8Char = ptChar;
            break;
        }
    }

    ptDescriptor->chCodeLength = ptUTF8Char->chCodeLength;
    ptDescriptor->tileChar.tRegion.tSize = ptUTF8Char->tCharSize;
    ptDescriptor->tileChar.tRegion.tLocation.iY = (int16_t)ptUTF8Char->hwIndex;

    ptDescriptor->iAdvance = ptUTF8Char->iAdvance;
    ptDescriptor->iBearingX= ptUTF8Char->iBearingX;
    ptDescriptor->iBearingY= ptUTF8Char->iBearingY;

    return ptDescriptor;
}

const
struct {
    implement(arm_2d_user_font_t);
    arm_2d_char_idx_t tUTF8Table;
} ARM_2D_FONT_arial_16_A1 = {

    .use_as__arm_2d_user_font_t = {
        .use_as__arm_2d_font_t = {
            .tileFont = impl_child_tile(
                c_tileUTF8arial_16A1Mask,
                0,          /* x offset */
                0,          /* y offset */
                9,        /* width */
                132         /* height */
            ),
            .tCharSize = {
                .iWidth = 9,
                .iHeight = 12,
            },
            .nCount =  11,                             //!< Character count
            .fnGetCharDescriptor = &__utf8_a1_font_get_char_descriptor,
            .fnDrawChar = &__arm_2d_lcd_text_default_a1_font_draw_char,
        },
        .hwCount = 1,
        .hwDefaultCharIndex = 1, /* tBlank */
    },

    .tUTF8Table = {
        .hwCount = 11,
        .hwOffset = 0,
    },
};

#undef __UTF8_FONT_SIZE_1__

ARM_SECTION("arm2d.asset.FONT")
const uint8_t c_bmpUTF8arial_16A2Font[] = {


    // Glyph for character {0x0a}
    0xff, 0xff, 0x00, 0x01, 0x40, 0x00, 0x01, 0x40, 0x00,
    0x01, 0x40, 0x00, 0x01, 0x40, 0x00, 0x01, 0x40, 0x00,
    0x01, 0x40, 0x00, 0x01, 0x40, 0x00, 0x01, 0x40, 0x00,
    0x01, 0x40, 0x00, 0xff, 0xff, 0x00,

    // Glyph for character {0x30}
    0xd0, 0x1f, 0x00, 0x74, 0x34, 0x00, 0x2c, 0xb0, 0x00,
    0x1c, 0xd0, 0x00, 0x0c, 0xd0, 0x00, 0x0d, 0xd0, 0x00,
    0x0d, 0xd0, 0x00, 0x0c, 0xd0, 0x00, 0x1c, 0xd0, 0x00,
    0x2c, 0xb0, 0x00, 0x74, 0x34, 0x00, 0xd0, 0x1f, 0x00,

    // Glyph for character {0x31}
    0x40, 0x03, 0x00, 0xc0, 0x03, 0x00, 0xf4, 0x03, 0x00,
    0x5d, 0x03, 0x00, 0x40, 0x03, 0x00, 0x40, 0x03, 0x00,
    0x40, 0x03, 0x00, 0x40, 0x03, 0x00, 0x40, 0x03, 0x00,
    0x40, 0x03, 0x00, 0x40, 0x03, 0x00, 0x40, 0x03, 0x00,

    // Glyph for character {0x32}
    0xe0, 0x1f, 0x00, 0x38, 0x74, 0x00, 0x1c, 0xe0, 0x00,
    0x00, 0xd0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x74, 0x00,
    0x00, 0x2c, 0x00, 0x00, 0x0b, 0x00, 0xc0, 0x02, 0x00,
    0xb0, 0x00, 0x00, 0x3c, 0x00, 0x00, 0xfd, 0xff, 0x00,

    // Glyph for character {0x33}
    0xe0, 0x0f, 0x00, 0x38, 0x38, 0x00, 0x1c, 0xb0, 0x00,
    0x00, 0xb0, 0x00, 0x00, 0x38, 0x00, 0x40, 0x2f, 0x00,
    0x00, 0xb0, 0x00, 0x00, 0xd0, 0x00, 0x00, 0xd0, 0x00,
    0x1c, 0xe0, 0x00, 0x38, 0x74, 0x00, 0xe0, 0x1f, 0x00,

    // Glyph for character {0x34}
    0x00, 0x2c, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x2f, 0x00,
    0xc0, 0x2e, 0x00, 0xe0, 0x2c, 0x00, 0x30, 0x2c, 0x00,
    0x2c, 0x2c, 0x00, 0x0d, 0x2c, 0x00, 0xff, 0xff, 0x00,
    0x00, 0x2c, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x2c, 0x00,

    // Glyph for character {0x35}
    0xf0, 0xbf, 0x00, 0x30, 0x00, 0x00, 0x34, 0x00, 0x00,
    0x28, 0x00, 0x00, 0xfc, 0x1f, 0x00, 0x3c, 0xb4, 0x00,
    0x00, 0xe0, 0x00, 0x00, 0xd0, 0x00, 0x00, 0xd0, 0x00,
    0x1c, 0xe0, 0x00, 0x38, 0x74, 0x00, 0xe0, 0x1f, 0x00,

    // Glyph for character {0x36}
    0xd0, 0x1f, 0x00, 0x70, 0x74, 0x00, 0x2c, 0xe0, 0x00,
    0x0c, 0x00, 0x00, 0x8d, 0x1f, 0x00, 0x7d, 0x74, 0x00,
    0x2d, 0xe0, 0x00, 0x1d, 0xd0, 0x00, 0x1c, 0xd0, 0x00,
    0x2c, 0xe0, 0x00, 0x74, 0x74, 0x00, 0xd0, 0x1f, 0x00,

    // Glyph for character {0x37}
    0xfc, 0xff, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x38, 0x00,
    0x00, 0x1c, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x07, 0x00,
    0x80, 0x03, 0x00, 0xc0, 0x02, 0x00, 0xc0, 0x01, 0x00,
    0xd0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00,

    // Glyph for character {0x38}
    0xd0, 0x1f, 0x00, 0x74, 0x34, 0x00, 0x2c, 0xb0, 0x00,
    0x2c, 0xb0, 0x00, 0x74, 0x74, 0x00, 0xe0, 0x2f, 0x00,
    0x38, 0xb4, 0x00, 0x1c, 0xd0, 0x00, 0x0d, 0xd0, 0x00,
    0x1c, 0xd0, 0x00, 0x38, 0xb4, 0x00, 0xe0, 0x1f, 0x00,

    // Glyph for character {0x39}
    0xd0, 0x0b, 0x00, 0x78, 0x34, 0x00, 0x1c, 0xa0, 0x00,
    0x0d, 0xd0, 0x00, 0x0d, 0xd0, 0x00, 0x1c, 0xe0, 0x00,
    0x78, 0xf4, 0x00, 0xe0, 0xdb, 0x00, 0x00, 0xd0, 0x00,
    0x1c, 0xa0, 0x00, 0x38, 0x38, 0x00, 0xe0, 0x0b, 0x00,
    // a white space
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
};

ARM_SECTION("arm2d.asset.FONT")
 const __ttf_char_descriptor_t c_tUTF8arial_16LookUpTableA2[] = {

    { 0, { 8, 11, }, 12, 2, 11, 1, {0x0a} },
    { 11, { 9, 12, }, 9, 0, 12, 1, {0x30} },
    { 23, { 5, 12, }, 9, 1, 12, 1, {0x31} },
    { 35, { 9, 12, }, 9, 0, 12, 1, {0x32} },
    { 47, { 9, 12, }, 9, 0, 12, 1, {0x33} },
    { 59, { 9, 12, }, 9, 0, 12, 1, {0x34} },
    { 71, { 9, 12, }, 9, 0, 12, 1, {0x35} },
    { 83, { 9, 12, }, 9, 0, 12, 1, {0x36} },
    { 95, { 9, 12, }, 9, 0, 12, 1, {0x37} },
    { 107, { 9, 12, }, 9, 0, 12, 1, {0x38} },
    { 119, { 9, 12, }, 9, 0, 12, 1, {0x39} },
    { 131, { 9, 12, }, 9, 0, 12, 1, {0x20} },
};



ARM_SECTION("arm2d.tile.c_tileUTF8arial_16A2Mask")
static const arm_2d_tile_t c_tileUTF8arial_16A2Mask = {
    .tRegion = {
        .tSize = {
            .iWidth = 9,
            .iHeight = 132,
        },
    },
    .tInfo = {
        .bIsRoot = true,
        .bHasEnforcedColour = true,
        .tColourInfo = {
            .chScheme = ARM_2D_COLOUR_2BIT,
        },
    },
    .pchBuffer = (uint8_t *)c_bmpUTF8arial_16A2Font,
};

#define __UTF8_FONT_SIZE_2__



static
IMPL_FONT_GET_CHAR_DESCRIPTOR(__utf8_a2_font_get_char_descriptor)
{
    assert(NULL != ptFont);
    assert(NULL != ptDescriptor);
    assert(NULL != pchCharCode);

    arm_2d_user_font_t *ptThis = (arm_2d_user_font_t *)ptFont;
    ARM_2D_UNUSED(ptThis);

    memset(ptDescriptor, 0, sizeof(arm_2d_char_descriptor_t));

    ptDescriptor->tileChar.ptParent = (arm_2d_tile_t *)&ptFont->tileFont;
    ptDescriptor->tileChar.tInfo.bDerivedResource = true;

    /* use the white space as the default char */
    __ttf_char_descriptor_t *ptUTF8Char =
        (__ttf_char_descriptor_t *)&c_tUTF8arial_16LookUpTableA2[dimof(c_tUTF8arial_16LookUpTableA2)-1];

    arm_foreach(__ttf_char_descriptor_t, c_tUTF8arial_16LookUpTableA2, ptChar) {
        if (0 == strncmp(   (char *)pchCharCode,
                            (char *)ptChar->chUTF8,
                            ptChar->chCodeLength)) {
            /* found the UTF8 char */
            ptUTF8Char = ptChar;
            break;
        }
    }

    ptDescriptor->chCodeLength = ptUTF8Char->chCodeLength;
    ptDescriptor->tileChar.tRegion.tSize = ptUTF8Char->tCharSize;
    ptDescriptor->tileChar.tRegion.tLocation.iY = (int16_t)ptUTF8Char->hwIndex;

    ptDescriptor->iAdvance = ptUTF8Char->iAdvance;
    ptDescriptor->iBearingX= ptUTF8Char->iBearingX;
    ptDescriptor->iBearingY= ptUTF8Char->iBearingY;

    return ptDescriptor;
}

const
struct {
    implement(arm_2d_user_font_t);
    arm_2d_char_idx_t tUTF8Table;
} ARM_2D_FONT_arial_16_A2 = {

    .use_as__arm_2d_user_font_t = {
        .use_as__arm_2d_font_t = {
            .tileFont = impl_child_tile(
                c_tileUTF8arial_16A2Mask,
                0,          /* x offset */
                0,          /* y offset */
                9,        /* width */
                132         /* height */
            ),
            .tCharSize = {
                .iWidth = 9,
                .iHeight = 12,
            },
            .nCount =  11,                             //!< Character count
            .fnGetCharDescriptor = &__utf8_a2_font_get_char_descriptor,
            .fnDrawChar = &__arm_2d_lcd_text_default_a2_font_draw_char,
        },
        .hwCount = 1,
        .hwDefaultCharIndex = 1, /* tBlank */
    },

    .tUTF8Table = {
        .hwCount = 11,
        .hwOffset = 0,
    },
};

#undef __UTF8_FONT_SIZE_2__

ARM_SECTION("arm2d.asset.FONT")
const uint8_t c_bmpUTF8arial_16A4Font[] = {


    // Glyph for character {0x0a}
    0xff, 0xff, 0xff, 0xff, 0x00, 0x04, 0x00, 0x00, 0x40,
    0x00, 0x04, 0x00, 0x00, 0x40, 0x00, 0x04, 0x00, 0x00,
    0x40, 0x00, 0x04, 0x00, 0x00, 0x40, 0x00, 0x04, 0x00,
    0x00, 0x40, 0x00, 0x04, 0x00, 0x00, 0x40, 0x00, 0x04,
    0x00, 0x00, 0x40, 0x00, 0x04, 0x00, 0x00, 0x40, 0x00,
    0x04, 0x00, 0x00, 0x40, 0x00, 0xff, 0xff, 0xff, 0xff,
    0x00,

    // Glyph for character {0x30}
    0x00, 0xd6, 0xcf, 0x04, 0x00, 0x50, 0x5f, 0x71, 0x2f,
    0x00, 0xd0, 0x09, 0x00, 0xac, 0x00, 0xf1, 0x04, 0x00,
    0xe7, 0x00, 0xf3, 0x02, 0x00, 0xf6, 0x01, 0xf4, 0x01,
    0x00, 0xf5, 0x01, 0xf4, 0x01, 0x00, 0xf5, 0x01, 0xf3,
    0x02, 0x00, 0xf6, 0x00, 0xf1, 0x04, 0x00, 0xe7, 0x00,
    0xd0, 0x08, 0x00, 0xac, 0x00, 0x50, 0x5f, 0x71, 0x2f,
    0x00, 0x00, 0xd6, 0xcf, 0x04, 0x00,

    // Glyph for character {0x31}
    0x00, 0x40, 0x0f, 0x00, 0x00, 0x00, 0xe3, 0x0f, 0x00,
    0x00, 0x60, 0xef, 0x0f, 0x00, 0x00, 0xf4, 0x77, 0x0f,
    0x00, 0x00, 0x11, 0x70, 0x0f, 0x00, 0x00, 0x00, 0x70,
    0x0f, 0x00, 0x00, 0x00, 0x70, 0x0f, 0x00, 0x00, 0x00,
    0x70, 0x0f, 0x00, 0x00, 0x00, 0x70, 0x0f, 0x00, 0x00,
    0x00, 0x70, 0x0f, 0x00, 0x00, 0x00, 0x70, 0x0f, 0x00,
    0x00, 0x00, 0x70, 0x0f, 0x00, 0x00,

    // Glyph for character {0x32}
    0x00, 0xd8, 0xdf, 0x06, 0x00, 0xb0, 0x3d, 0x50, 0x6f,
    0x00, 0xf1, 0x04, 0x00, 0xe9, 0x00, 0x00, 0x00, 0x00,
    0xf7, 0x00, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00,
    0x40, 0x6f, 0x00, 0x00, 0x00, 0xe2, 0x0a, 0x00, 0x00,
    0x10, 0xbd, 0x00, 0x00, 0x00, 0xd1, 0x0a, 0x00, 0x00,
    0x10, 0xad, 0x00, 0x00, 0x00, 0xd0, 0x0c, 0x00, 0x00,
    0x00, 0xf6, 0xff, 0xff, 0xff, 0x01,

    // Glyph for character {0x33}
    0x00, 0xe8, 0xcf, 0x03, 0x00, 0x80, 0x3d, 0x80, 0x2f,
    0x00, 0xf0, 0x05, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x00,
    0x8e, 0x00, 0x00, 0x00, 0x91, 0x2e, 0x00, 0x00, 0x70,
    0xfe, 0x08, 0x00, 0x00, 0x00, 0x20, 0xae, 0x00, 0x00,
    0x00, 0x00, 0xf7, 0x01, 0x00, 0x00, 0x00, 0xf5, 0x02,
    0xf2, 0x04, 0x00, 0xe9, 0x00, 0xb0, 0x2d, 0x60, 0x6f,
    0x00, 0x00, 0xe8, 0xdf, 0x05, 0x00,

    // Glyph for character {0x34}
    0x00, 0x00, 0xd0, 0x09, 0x00, 0x00, 0x00, 0xf8, 0x09,
    0x00, 0x00, 0x30, 0xff, 0x09, 0x00, 0x00, 0xd0, 0xd8,
    0x09, 0x00, 0x00, 0xd8, 0xd0, 0x09, 0x00, 0x20, 0x3f,
    0xd0, 0x09, 0x00, 0xc0, 0x09, 0xd0, 0x09, 0x00, 0xd7,
    0x00, 0xd0, 0x09, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x02,
    0x00, 0x00, 0xd0, 0x09, 0x00, 0x00, 0x00, 0xd0, 0x09,
    0x00, 0x00, 0x00, 0xd0, 0x09, 0x00,

    // Glyph for character {0x35}
    0x10, 0xff, 0xff, 0xbf, 0x00, 0x30, 0x1f, 0x00, 0x00,
    0x00, 0x60, 0x0e, 0x00, 0x00, 0x00, 0x90, 0x0b, 0x00,
    0x00, 0x00, 0xc0, 0xcc, 0xef, 0x07, 0x00, 0xf0, 0x2c,
    0x50, 0x8f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00,
    0x00, 0x00, 0xf4, 0x03, 0x00, 0x00, 0x00, 0xf5, 0x02,
    0xf3, 0x04, 0x00, 0xe9, 0x00, 0xb0, 0x3d, 0x60, 0x5f,
    0x00, 0x10, 0xe9, 0xdf, 0x05, 0x00,

    // Glyph for character {0x36}
    0x00, 0xc4, 0xdf, 0x07, 0x00, 0x30, 0x6f, 0x40, 0x6f,
    0x00, 0xc0, 0x09, 0x00, 0xd9, 0x00, 0xf1, 0x03, 0x00,
    0x00, 0x00, 0xf4, 0xb3, 0xef, 0x07, 0x00, 0xf5, 0x5d,
    0x50, 0x6f, 0x00, 0xf6, 0x08, 0x00, 0xe8, 0x00, 0xf5,
    0x04, 0x00, 0xf5, 0x01, 0xf2, 0x04, 0x00, 0xf5, 0x01,
    0xe0, 0x09, 0x00, 0xd9, 0x00, 0x50, 0x5f, 0x50, 0x6f,
    0x00, 0x00, 0xd5, 0xdf, 0x06, 0x00,

    // Glyph for character {0x37}
    0xf3, 0xff, 0xff, 0xff, 0x02, 0x00, 0x00, 0x10, 0xae,
    0x00, 0x00, 0x00, 0xa0, 0x0e, 0x00, 0x00, 0x00, 0xf3,
    0x05, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x20,
    0x6f, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00,
    0xd0, 0x0a, 0x00, 0x00, 0x00, 0xf1, 0x05, 0x00, 0x00,
    0x00, 0xf5, 0x02, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00,
    0x00, 0x00, 0xd9, 0x00, 0x00, 0x00,

    // Glyph for character {0x38}
    0x00, 0xd6, 0xcf, 0x04, 0x00, 0x60, 0x4f, 0x70, 0x3f,
    0x00, 0xc0, 0x0a, 0x00, 0x9d, 0x00, 0xd0, 0x0a, 0x00,
    0xac, 0x00, 0x60, 0x4f, 0x60, 0x4f, 0x00, 0x00, 0xfa,
    0xff, 0x08, 0x00, 0xb0, 0x3e, 0x50, 0x8f, 0x00, 0xf3,
    0x05, 0x00, 0xf7, 0x00, 0xf5, 0x02, 0x00, 0xf4, 0x02,
    0xf2, 0x04, 0x00, 0xf7, 0x00, 0xa0, 0x3e, 0x40, 0x8e,
    0x00, 0x00, 0xe8, 0xdf, 0x07, 0x00,

    // Glyph for character {0x39}
    0x00, 0xe7, 0xbf, 0x03, 0x00, 0x90, 0x5f, 0x61, 0x3f,
    0x00, 0xf1, 0x07, 0x00, 0xba, 0x00, 0xf4, 0x03, 0x00,
    0xf6, 0x00, 0xf4, 0x02, 0x00, 0xf6, 0x02, 0xf1, 0x06,
    0x00, 0xfa, 0x03, 0x90, 0x4e, 0x60, 0xfe, 0x02, 0x00,
    0xe9, 0xaf, 0xf5, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x00,
    0xf0, 0x05, 0x00, 0x9b, 0x00, 0x90, 0x2d, 0x80, 0x1e,
    0x00, 0x00, 0xe9, 0xbf, 0x02, 0x00,
    // a white space
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
};

ARM_SECTION("arm2d.asset.FONT")
 const __ttf_char_descriptor_t c_tUTF8arial_16LookUpTableA4[] = {

    { 0, { 8, 11, }, 12, 2, 11, 1, {0x0a} },
    { 11, { 9, 12, }, 9, 0, 12, 1, {0x30} },
    { 23, { 5, 12, }, 9, 1, 12, 1, {0x31} },
    { 35, { 9, 12, }, 9, 0, 12, 1, {0x32} },
    { 47, { 9, 12, }, 9, 0, 12, 1, {0x33} },
    { 59, { 9, 12, }, 9, 0, 12, 1, {0x34} },
    { 71, { 9, 12, }, 9, 0, 12, 1, {0x35} },
    { 83, { 9, 12, }, 9, 0, 12, 1, {0x36} },
    { 95, { 9, 12, }, 9, 0, 12, 1, {0x37} },
    { 107, { 9, 12, }, 9, 0, 12, 1, {0x38} },
    { 119, { 9, 12, }, 9, 0, 12, 1, {0x39} },
    { 131, { 9, 12, }, 9, 0, 12, 1, {0x20} },
};



ARM_SECTION("arm2d.tile.c_tileUTF8arial_16A4Mask")
static const arm_2d_tile_t c_tileUTF8arial_16A4Mask = {
    .tRegion = {
        .tSize = {
            .iWidth = 9,
            .iHeight = 132,
        },
    },
    .tInfo = {
        .bIsRoot = true,
        .bHasEnforcedColour = true,
        .tColourInfo = {
            .chScheme = ARM_2D_COLOUR_4BIT,
        },
    },
    .pchBuffer = (uint8_t *)c_bmpUTF8arial_16A4Font,
};

#define __UTF8_FONT_SIZE_4__



static
IMPL_FONT_GET_CHAR_DESCRIPTOR(__utf8_a4_font_get_char_descriptor)
{
    assert(NULL != ptFont);
    assert(NULL != ptDescriptor);
    assert(NULL != pchCharCode);

    arm_2d_user_font_t *ptThis = (arm_2d_user_font_t *)ptFont;
    ARM_2D_UNUSED(ptThis);

    memset(ptDescriptor, 0, sizeof(arm_2d_char_descriptor_t));

    ptDescriptor->tileChar.ptParent = (arm_2d_tile_t *)&ptFont->tileFont;
    ptDescriptor->tileChar.tInfo.bDerivedResource = true;

    /* use the white space as the default char */
    __ttf_char_descriptor_t *ptUTF8Char =
        (__ttf_char_descriptor_t *)&c_tUTF8arial_16LookUpTableA4[dimof(c_tUTF8arial_16LookUpTableA4)-1];

    arm_foreach(__ttf_char_descriptor_t, c_tUTF8arial_16LookUpTableA4, ptChar) {
        if (0 == strncmp(   (char *)pchCharCode,
                            (char *)ptChar->chUTF8,
                            ptChar->chCodeLength)) {
            /* found the UTF8 char */
            ptUTF8Char = ptChar;
            break;
        }
    }

    ptDescriptor->chCodeLength = ptUTF8Char->chCodeLength;
    ptDescriptor->tileChar.tRegion.tSize = ptUTF8Char->tCharSize;
    ptDescriptor->tileChar.tRegion.tLocation.iY = (int16_t)ptUTF8Char->hwIndex;

    ptDescriptor->iAdvance = ptUTF8Char->iAdvance;
    ptDescriptor->iBearingX= ptUTF8Char->iBearingX;
    ptDescriptor->iBearingY= ptUTF8Char->iBearingY;

    return ptDescriptor;
}

const
struct {
    implement(arm_2d_user_font_t);
    arm_2d_char_idx_t tUTF8Table;
} ARM_2D_FONT_arial_16_A4 = {

    .use_as__arm_2d_user_font_t = {
        .use_as__arm_2d_font_t = {
            .tileFont = impl_child_tile(
                c_tileUTF8arial_16A4Mask,
                0,          /* x offset */
                0,          /* y offset */
                9,        /* width */
                132         /* height */
            ),
            .tCharSize = {
                .iWidth = 9,
                .iHeight = 12,
            },
            .nCount =  11,                             //!< Character count
            .fnGetCharDescriptor = &__utf8_a4_font_get_char_descriptor,
            .fnDrawChar = &__arm_2d_lcd_text_default_a4_font_draw_char,
        },
        .hwCount = 1,
        .hwDefaultCharIndex = 1, /* tBlank */
    },

    .tUTF8Table = {
        .hwCount = 11,
        .hwOffset = 0,
    },
};

#undef __UTF8_FONT_SIZE_4__

ARM_SECTION("arm2d.asset.FONT")
const uint8_t c_bmpUTF8arial_16A8Font[] = {


    // Glyph for character {0x0a}
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
    0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,

    // Glyph for character {0x30}
    0x00, 0x00, 0x60, 0xd9, 0xf7, 0xcc, 0x42, 0x00, 0x00,
    0x00, 0x52, 0xf6, 0x52, 0x12, 0x7e, 0xf7, 0x2c, 0x00,
    0x00, 0xd2, 0x90, 0x00, 0x00, 0x00, 0xc1, 0xa2, 0x00,
    0x17, 0xff, 0x4d, 0x00, 0x00, 0x00, 0x7e, 0xea, 0x00,
    0x3e, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x60, 0xff, 0x10,
    0x4d, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x54, 0xff, 0x1e,
    0x4f, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x55, 0xff, 0x1c,
    0x3f, 0xff, 0x2a, 0x00, 0x00, 0x00, 0x60, 0xff, 0x0d,
    0x19, 0xff, 0x48, 0x00, 0x00, 0x00, 0x7e, 0xe6, 0x00,
    0x00, 0xd4, 0x8b, 0x00, 0x00, 0x00, 0xc1, 0xa1, 0x00,
    0x00, 0x58, 0xf7, 0x57, 0x12, 0x7d, 0xf6, 0x2b, 0x00,
    0x00, 0x00, 0x67, 0xde, 0xf7, 0xcc, 0x42, 0x00, 0x00,

    // Glyph for character {0x31}
    0x00, 0x00, 0x00, 0x41, 0xf7, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x30, 0xec, 0xf8, 0x00, 0x00, 0x00, 0x00,
    0x04, 0x6e, 0xf5, 0xee, 0xf8, 0x00, 0x00, 0x00, 0x00,
    0x40, 0xf4, 0x7c, 0x73, 0xf8, 0x00, 0x00, 0x00, 0x00,
    0x17, 0x16, 0x00, 0x70, 0xf8, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x70, 0xf8, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x70, 0xf8, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x70, 0xf8, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x70, 0xf8, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x70, 0xf8, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x70, 0xf8, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x70, 0xf8, 0x00, 0x00, 0x00, 0x00,

    // Glyph for character {0x32}
    0x00, 0x0e, 0x8c, 0xdf, 0xf6, 0xd3, 0x64, 0x00, 0x00,
    0x00, 0xb3, 0xd2, 0x31, 0x0b, 0x55, 0xf7, 0x6b, 0x00,
    0x1c, 0xff, 0x4d, 0x00, 0x00, 0x00, 0x93, 0xe1, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0xff, 0x04,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0xdc, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xff, 0x67, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x21, 0xe9, 0xaa, 0x01, 0x00,
    0x00, 0x00, 0x00, 0x19, 0xdb, 0xb4, 0x06, 0x00, 0x00,
    0x00, 0x00, 0x19, 0xd7, 0xad, 0x06, 0x00, 0x00, 0x00,
    0x00, 0x1b, 0xd9, 0xa7, 0x04, 0x00, 0x00, 0x00, 0x00,
    0x0b, 0xd6, 0xc6, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x66, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10,

    // Glyph for character {0x33}
    0x00, 0x05, 0x80, 0xe0, 0xf6, 0xc5, 0x3e, 0x00, 0x00,
    0x00, 0x8f, 0xde, 0x32, 0x0d, 0x83, 0xf7, 0x29, 0x00,
    0x0d, 0xf7, 0x5d, 0x00, 0x00, 0x01, 0xe8, 0x87, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xef, 0x87, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x18, 0x9a, 0xef, 0x23, 0x00,
    0x00, 0x00, 0x00, 0x72, 0xe3, 0xfe, 0x8e, 0x05, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0xea, 0xa1, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xfe, 0x10,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0xff, 0x24,
    0x2f, 0xff, 0x42, 0x00, 0x00, 0x00, 0x97, 0xee, 0x05,
    0x00, 0xb8, 0xd5, 0x2e, 0x0e, 0x67, 0xfb, 0x69, 0x00,
    0x00, 0x0d, 0x8d, 0xe1, 0xf9, 0xd2, 0x5a, 0x00, 0x00,

    // Glyph for character {0x34}
    0x00, 0x00, 0x00, 0x00, 0x09, 0xda, 0x94, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x8c, 0xff, 0x94, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x36, 0xf8, 0xf0, 0x94, 0x00, 0x00,
    0x00, 0x00, 0x06, 0xd4, 0x87, 0xd4, 0x94, 0x00, 0x00,
    0x00, 0x00, 0x82, 0xd8, 0x08, 0xd4, 0x94, 0x00, 0x00,
    0x00, 0x2f, 0xf8, 0x3b, 0x00, 0xd4, 0x94, 0x00, 0x00,
    0x03, 0xcc, 0x92, 0x00, 0x00, 0xd4, 0x94, 0x00, 0x00,
    0x78, 0xdf, 0x0b, 0x00, 0x00, 0xd4, 0x94, 0x00, 0x00,
    0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x20,
    0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x94, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x94, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x94, 0x00, 0x00,

    // Glyph for character {0x35}
    0x00, 0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb8, 0x00,
    0x00, 0x3f, 0xff, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x6f, 0xe4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x9e, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0xcd, 0xcd, 0xcb, 0xf6, 0xe3, 0x7b, 0x02, 0x00,
    0x04, 0xf8, 0xc1, 0x26, 0x0d, 0x5c, 0xf6, 0x8c, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0xfa, 0x12,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0xff, 0x3c,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0xff, 0x28,
    0x30, 0xff, 0x4d, 0x00, 0x00, 0x00, 0x98, 0xe5, 0x05,
    0x00, 0xbd, 0xda, 0x33, 0x0e, 0x69, 0xfb, 0x5d, 0x00,
    0x00, 0x10, 0x90, 0xe1, 0xf8, 0xd3, 0x5b, 0x00, 0x00,

    // Glyph for character {0x36}
    0x00, 0x00, 0x45, 0xca, 0xf7, 0xdf, 0x77, 0x01, 0x00,
    0x00, 0x3f, 0xf8, 0x6a, 0x0b, 0x4b, 0xf5, 0x6e, 0x00,
    0x00, 0xc8, 0x95, 0x00, 0x00, 0x00, 0x96, 0xd4, 0x00,
    0x19, 0xff, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x46, 0xff, 0x34, 0xb5, 0xf6, 0xe4, 0x74, 0x00, 0x00,
    0x5b, 0xff, 0xd8, 0x54, 0x0e, 0x56, 0xf6, 0x6a, 0x00,
    0x60, 0xff, 0x80, 0x00, 0x00, 0x00, 0x8d, 0xeb, 0x00,
    0x54, 0xff, 0x44, 0x00, 0x00, 0x00, 0x53, 0xff, 0x1b,
    0x2f, 0xff, 0x4a, 0x00, 0x00, 0x00, 0x57, 0xff, 0x1b,
    0x02, 0xe6, 0x96, 0x00, 0x00, 0x00, 0x95, 0xdf, 0x00,
    0x00, 0x5f, 0xfa, 0x5f, 0x0c, 0x59, 0xf9, 0x60, 0x00,
    0x00, 0x00, 0x5a, 0xd4, 0xf9, 0xda, 0x63, 0x00, 0x00,

    // Glyph for character {0x37}
    0x3c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x28,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0xe6, 0xa5, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0xe4, 0x0c, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x37, 0xff, 0x5d, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0xba, 0xd6, 0x01, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x27, 0xff, 0x67, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x89, 0xf4, 0x0a, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0xd8, 0xab, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x1f, 0xff, 0x5c, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x54, 0xff, 0x23, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x80, 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x99, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00,

    // Glyph for character {0x38}
    0x00, 0x01, 0x6d, 0xd9, 0xf4, 0xcd, 0x4a, 0x00, 0x00,
    0x00, 0x69, 0xf8, 0x4d, 0x0d, 0x71, 0xfd, 0x3b, 0x00,
    0x00, 0xca, 0xa3, 0x00, 0x00, 0x00, 0xd2, 0x9e, 0x00,
    0x00, 0xd3, 0xa4, 0x00, 0x00, 0x00, 0xce, 0xac, 0x00,
    0x00, 0x6c, 0xf7, 0x49, 0x0b, 0x67, 0xfd, 0x48, 0x00,
    0x00, 0x06, 0xab, 0xff, 0xff, 0xff, 0x89, 0x00, 0x00,
    0x00, 0xb2, 0xe1, 0x3d, 0x0d, 0x55, 0xf3, 0x84, 0x00,
    0x32, 0xff, 0x51, 0x00, 0x00, 0x00, 0x7a, 0xf9, 0x0f,
    0x51, 0xff, 0x20, 0x00, 0x00, 0x00, 0x47, 0xff, 0x2c,
    0x2c, 0xff, 0x4e, 0x00, 0x00, 0x00, 0x73, 0xfa, 0x0f,
    0x00, 0xaf, 0xe0, 0x3b, 0x0a, 0x4c, 0xee, 0x89, 0x00,
    0x00, 0x08, 0x8a, 0xe4, 0xfb, 0xdc, 0x74, 0x01, 0x00,

    // Glyph for character {0x39}
    0x00, 0x02, 0x7f, 0xe4, 0xf4, 0xbf, 0x37, 0x00, 0x00,
    0x00, 0x90, 0xf4, 0x56, 0x10, 0x6d, 0xf5, 0x35, 0x00,
    0x17, 0xfb, 0x7c, 0x00, 0x00, 0x00, 0xae, 0xbe, 0x00,
    0x48, 0xff, 0x32, 0x00, 0x00, 0x00, 0x6e, 0xfc, 0x09,
    0x43, 0xff, 0x28, 0x00, 0x00, 0x00, 0x6b, 0xff, 0x26,
    0x18, 0xfd, 0x64, 0x00, 0x00, 0x00, 0xa6, 0xff, 0x31,
    0x00, 0x97, 0xe9, 0x45, 0x0e, 0x64, 0xe3, 0xff, 0x27,
    0x00, 0x07, 0x92, 0xee, 0xf1, 0xa1, 0x5b, 0xff, 0x15,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0xe5, 0x00,
    0x07, 0xf6, 0x5f, 0x00, 0x00, 0x00, 0xbf, 0x98, 0x00,
    0x00, 0x9a, 0xd8, 0x27, 0x0e, 0x8d, 0xea, 0x1e, 0x00,
    0x00, 0x0b, 0x94, 0xe8, 0xf0, 0xb3, 0x29, 0x00, 0x00,
    // a white space
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
};

ARM_SECTION("arm2d.asset.FONT")
 const __ttf_char_descriptor_t c_tUTF8arial_16LookUpTableA8[] = {

    { 0, { 8, 11, }, 12, 2, 11, 1, {0x0a} },
    { 11, { 9, 12, }, 9, 0, 12, 1, {0x30} },
    { 23, { 5, 12, }, 9, 1, 12, 1, {0x31} },
    { 35, { 9, 12, }, 9, 0, 12, 1, {0x32} },
    { 47, { 9, 12, }, 9, 0, 12, 1, {0x33} },
    { 59, { 9, 12, }, 9, 0, 12, 1, {0x34} },
    { 71, { 9, 12, }, 9, 0, 12, 1, {0x35} },
    { 83, { 9, 12, }, 9, 0, 12, 1, {0x36} },
    { 95, { 9, 12, }, 9, 0, 12, 1, {0x37} },
    { 107, { 9, 12, }, 9, 0, 12, 1, {0x38} },
    { 119, { 9, 12, }, 9, 0, 12, 1, {0x39} },
    { 131, { 9, 12, }, 9, 0, 12, 1, {0x20} },
};



ARM_SECTION("arm2d.tile.c_tileUTF8arial_16A8Mask")
static const arm_2d_tile_t c_tileUTF8arial_16A8Mask = {
    .tRegion = {
        .tSize = {
            .iWidth = 9,
            .iHeight = 132,
        },
    },
    .tInfo = {
        .bIsRoot = true,
        .bHasEnforcedColour = true,
        .tColourInfo = {
            .chScheme = ARM_2D_COLOUR_8BIT,
        },
    },
    .pchBuffer = (uint8_t *)c_bmpUTF8arial_16A8Font,
};

#define __UTF8_FONT_SIZE_8__



static
IMPL_FONT_GET_CHAR_DESCRIPTOR(__utf8_a8_font_get_char_descriptor)
{
    assert(NULL != ptFont);
    assert(NULL != ptDescriptor);
    assert(NULL != pchCharCode);

    arm_2d_user_font_t *ptThis = (arm_2d_user_font_t *)ptFont;
    ARM_2D_UNUSED(ptThis);

    memset(ptDescriptor, 0, sizeof(arm_2d_char_descriptor_t));

    ptDescriptor->tileChar.ptParent = (arm_2d_tile_t *)&ptFont->tileFont;
    ptDescriptor->tileChar.tInfo.bDerivedResource = true;

    /* use the white space as the default char */
    __ttf_char_descriptor_t *ptUTF8Char =
        (__ttf_char_descriptor_t *)&c_tUTF8arial_16LookUpTableA8[dimof(c_tUTF8arial_16LookUpTableA8)-1];

    arm_foreach(__ttf_char_descriptor_t, c_tUTF8arial_16LookUpTableA8, ptChar) {
        if (0 == strncmp(   (char *)pchCharCode,
                            (char *)ptChar->chUTF8,
                            ptChar->chCodeLength)) {
            /* found the UTF8 char */
            ptUTF8Char = ptChar;
            break;
        }
    }

    ptDescriptor->chCodeLength = ptUTF8Char->chCodeLength;
    ptDescriptor->tileChar.tRegion.tSize = ptUTF8Char->tCharSize;
    ptDescriptor->tileChar.tRegion.tLocation.iY = (int16_t)ptUTF8Char->hwIndex;

    ptDescriptor->iAdvance = ptUTF8Char->iAdvance;
    ptDescriptor->iBearingX= ptUTF8Char->iBearingX;
    ptDescriptor->iBearingY= ptUTF8Char->iBearingY;

    return ptDescriptor;
}

const
struct {
    implement(arm_2d_user_font_t);
    arm_2d_char_idx_t tUTF8Table;
} ARM_2D_FONT_arial_16_A8 = {

    .use_as__arm_2d_user_font_t = {
        .use_as__arm_2d_font_t = {
            .tileFont = impl_child_tile(
                c_tileUTF8arial_16A8Mask,
                0,          /* x offset */
                0,          /* y offset */
                9,        /* width */
                132         /* height */
            ),
            .tCharSize = {
                .iWidth = 9,
                .iHeight = 12,
            },
            .nCount =  11,                             //!< Character count
            .fnGetCharDescriptor = &__utf8_a8_font_get_char_descriptor,
            .fnDrawChar = &__arm_2d_lcd_text_default_a8_font_draw_char,
        },
        .hwCount = 1,
        .hwDefaultCharIndex = 1, /* tBlank */
    },

    .tUTF8Table = {
        .hwCount = 11,
        .hwOffset = 0,
    },
};

#undef __UTF8_FONT_SIZE_8__



#if defined(__clang__)
#   pragma clang diagnostic pop
#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
#   pragma diag_warning=1296
#endif

